package academico;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import academico.modelo.Aluno;

/**
 * Session Bean implementation class cadastroDaoBean
 */
@Stateless
@LocalBean
public class cadastroDaoBean implements cadastroDao {

	@PersistenceContext(unitName="academico")
	EntityManager em;
	
    public cadastroDaoBean() {
        // TODO Auto-generated constructor stub
    }

	@Override
	public void cadastrarAluno(Aluno aluno) {
		em.persist(aluno);
		
	}

	@Override
	public Aluno getAlunoById(int id) {
		Query query = em.createNamedQuery("findAlunoById");
		return (Aluno) query.getSingleResult();
	}

}

